#include<stdio.h>
static int dy(int m,int n)
{
	int temp = 0,i=0;
	if(n>m) 
	{
		temp = n;
		n = m;
		m = temp;
	}
	for(i=n;i>=1;i--)
	{
		if (n % i == 0 && m % i == 0) return i;
	}
}
int main() 
{
	int p = 0, q = 0;
	scanf_s("%d%d", &p, &q);
	printf("%d", dy(p, q));
	return 0;
}